package cn.usian.service.impl;

import cn.usian.common.R;
import cn.usian.mapper.UserMapper;
import cn.usian.pojo.User;
import cn.usian.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserMapper userMapper;

    @Override
    public R<User> login(User user) {
        //1.查询用户
        User login = userMapper.login(user);
        if (login==null){
            return R.error("用户不存在！");
        }

        //2.校验密码
        if (!login.getPassword().equals(user.getPassword())){
            return R.error("密码错误！");
        }

        return R.success(login);
    }
}
